import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 沈明月
 * Date: 2022-11-02
 * Time: 10:25
 */
public class TestSix {
//阶乘相关：
//求一个数的阶乘：
    public static void main1(String[] args) {
        //输入希望求的数的阶乘
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        System.out.println(ret);
    }

//求前几个数的阶乘：
    public static void main2(String[] args) {
        //输入你希望求到第几个数（假设求到a）的阶乘和（连续的从1开始加到a）：
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int ret = 1;
            for (int j = 1; j <= i; j++) {
                ret *= j;
            }
            sum += ret;
        }
        System.out.println("从1的阶乘开始加，加到"+n+"的阶乘的和是："+sum);
    }
}
